// miniprogram/pages/home/home.js
import {gethomedata,getgoodsdata} from '../../service/home.js'
Page({
  /**   * 页面的初始数据   */
  data: {
    'banners':[],
    'recommends':[],
    'tabcontrols':["流行","新款","精选"],
    goods:{
      'pop':{page:0,list:[]},
      'new':{page:0,list:[]},
      'sell':{page:0,list:[]}
    }
  },
  // 监听事件

  // 网络请求函数
  _gethomedata() {
    gethomedata().then(res=> {
      // console.log(res);
      const banners = res.data.data.banner.list;
      const recommends = res.data.data.recommend.list;
      this.setData({
        banners,
        recommends
      })
    })
  },

  _getgoodsdata(type) {
    getgoodsdata(type).then(res=> {
      console.log(res);
     
    })
  },
  /**   * 生命周期函数--监听页面加载   */
  onLoad:function(options){
    this._gethomedata()
    this._getgoodsdata('pop')
    }
  })